import React from "react"

class Cal extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      celsius: 0
    }
    // this.myref = React.forwardRef((props, ref) => <h3
    // ref={this.myref}>摄氏度：{this.props.celsius     ? this.props.celsius     :
    // ''}</h3>)
  }

  celChange = (e) => {
    // this.setState({celsius: e.target.value})
    this
      .props
      .onCelChange(e.target.value)
    console.log(this.props);
  }

  toFah = () => {
    return (this.props.celsius - 32) * 5 / 9
  }
  render() {
    return (
      <div>
        <h3>摄氏度：{this.props.celsius
            ? this.props.celsius
            : ''}</h3>
        <input
          type='number'
          value={this.props.celsius
          ? this.props.celsius
          : ''}
          onChange={this.celChange}/>
      </div>
    )
  }
}

export default Cal